Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF+TST: test /fix for signed int data type #302

Merged
merged 2 commits into from
Apr 20, 2015

Conversation

matthew-brett
Copy link
Member

We were incorrectly loading signed ints as unsigned; fix and test.

See : #297 for motivation.

We were incorrectly loading signed ints as unsigned; fix and test.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 94.36% when pulling 5bffac6 on matthew-brett:fix-negative-ecat into b0a8006 on nipy:master.

@matthew-brett
Copy link
Member Author

Any reviews here? I think this is a bug and I will merge soon unless I hear otherwise.

(4, 'ECAT7_VAXR4', np.float32),
(5, 'ECAT7_IEEER4', np.float32),
(6, 'ECAT7_SUNI2', np.uint16),
(6, 'ECAT7_SUNI2', np.int16),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do indeed look like they were wrong. Any idea why the original author would have head float32 for a datatype that has I4 at the end and uint16 when everything else is int*?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea I'm afraid. I don't think I've got any real data to test with, for ECAT_VAXI4 either, so it's only a guess.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if it's right, but it's at least another reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and it seems to match what you've done here in any case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha - yes - thanks for tracking that down.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - this:

http://www.turkupetcentre.net/software/libdoc/libtpcimgio/ecat7r_8c_source.html#l00720

suggests to me that the BYTE type is signed - do you agree?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pointer starts out as a char * and isn't re-cast as anything else, which makes me think it is unsigned. What made you think it was signed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some trivial testing with gcc:

#include <limits.h>
int main() {
    printf("Char min is %d\n", CHAR_MIN);
}

But I see in fact it is undefined ...

http://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only ECAT files I can find on our system have ECAT7_SUNI2 type, so very hard to know what the intention was.

@larsoner
Copy link
Contributor

LGTM, +1 for merge. My comment above is just a question for my own edification.

Eric Larson tracked down the relevant documentation for the datatypes.
We discovered that ECAT7_BYTE might be signed int, but we have no data
to test with, so leaving as is for now.
@matthew-brett
Copy link
Member Author

Thanks - I added a few lines pointing to the docs you found, merging.

matthew-brett added a commit that referenced this pull request Apr 20, 2015
BF+TST: test /fix for signed int data type

We were incorrectly loading signed ints as unsigned; fix and test.

See gh-297 for motivation.
@matthew-brett matthew-brett merged commit b03213c into nipy:master Apr 20, 2015
grlee77 pushed a commit to grlee77/nibabel that referenced this pull request Mar 15, 2016
BF+TST: test /fix for signed int data type

We were incorrectly loading signed ints as unsigned; fix and test.

See nipygh-297 for motivation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants